package display 
{
	import adobe.utils.CustomActions;
	import controller.Controller;
	import events.DisplayEvent;
	import flash.display.BitmapData;
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import com.greensock.TweenLite;
	import flash.filters.GlowFilter;
	import com.greensock.plugins.TweenPlugin;
    import com.greensock.plugins.GlowFilterPlugin;
	import com.greensock.easing.Strong;
	
	/**
	 * ...
	 * @author Henrik Riise Hansen
	 */
	public class DisplayHighLight extends MovieClip
	{
		private var s:Sprite;
		
		private var sHeight:int;
		private var sWidth:int;
		
		private var xPos:int;
		private var yPos:int;
		
		private var control:Controller;
		private var item:String;
		
		private var tile:BitmapData;
		
		private var gf:GlowFilter;
		private var gfColor:uint = 0xffffff;
		
		public function DisplayHighLight(ctr:Controller,_item:String,_height:int = 0,_width:int= 0,_xpos:int = 0,_ypos:int=0) 
		{
			TweenPlugin.activate([GlowFilterPlugin]);
			
			control = ctr;
			control.addEventListener(DisplayEvent.ON_HIGHLIGHT, onHighLight);
			
			item = _item;
			
			sHeight = _height;
			sWidth = _width;
			
			xPos = _xpos;
			yPos = _ypos;
			
			build();
		}
		
		private function onHighLight(e:DisplayEvent):void
		{
			if (item == e.data.item)
			 {
				 switch(e.data.state)
				 {
					 case 'over':
					 s.visible = true;
					 break;
					 
					 case 'out':
					 s.visible = false;
					 break;
				 }
			 }
		}
		
		private function bitmapfill():void
		{
			s = new Sprite;
			
			var bitmap:BitmapData = new Redbg();
			
			s.graphics.beginBitmapFill(bitmap);
			s.graphics.drawRect(0, 0, sWidth, sHeight);
			s.graphics.endFill();
			s.alpha = 0;
			
			addChild(s);
			
			//TweenLite.to(obj, 0.5, {glowFilter:{color:0xffffff, blurX:0, blurY:0, strength:1, alpha:1}});
		}
		
		private function purpleLine():void
		{
			s = new Sprite;
			
			s.graphics.lineStyle(4, 0xff66ff);
			s.graphics.drawRect(xPos,yPos, sWidth, sHeight);
			s.graphics.endFill();
			s.visible = false;
			
			addChild(s);
		}
		
		private function build():void
		{
			purpleLine();
		}
	}
}